Skip to content

test(openclaw): run the plugin against a real OpenClaw host - #2685

Merged
AlexStocks merged 1 commit into
oceanbase:masterfrom
Fengzdadi:test/openclaw-service-chain-e2e
Nov 17, 2026
Merged

AlexStocks merged 1 commit into
oceanbase:masterfrom
Fengzdadi:test/openclaw-service-chain-e2e

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

No tracking issue. This adds the OpenClaw member of the real-host service-chain E2E set, beside Pi (#2531), OpenCode (#2533), Codex (#2624), and Bub (#2649).

Rationale for this change

The OpenClaw plugin's tests drive the plugin with simulated hook contexts, so they cannot show what OpenClaw itself sends. These cases run the real host instead. A pinned OpenClaw 2026.8.1 Gateway loads the plugin's built bundle and talks to a real PowerContext Server, with a deterministic local model fixture standing in for the model. Each case checks one promise from the OpenClaw integration docs.

Two of those promises were broken against the real host, and both are now fixed on master:

What changes are included in this PR?

  • tests/e2e/test_openclaw_service_chain.py. A real openclaw gateway run process loads the plugin through openclaw plugins install --link --force --accept-capabilities, and openclaw agent submits each turn as an ordinary Gateway client. The Server runs in process on SQLite with bearer auth. Seven cases:
    • Recall. A prompt captured in one session is recalled in a later session. The model request carries the wrapped prepared context before the question, and the history the Gateway stores carries none of it.
    • Scope resolution. An explicit scopeId wins over durable bindings. Among the bindings, the OpenClaw session wins over the active project, which wins over the agent.
    • Settings. autoRecall and autoCapture work independently, and explicit memory tools keep working with both off.
    • Memory tools. powercontext_memory_store and powercontext_memory_search reach the session-bound Scope.
    • Excluded sessions. Group and incognito sessions are neither prepared nor captured.
    • Pre-compaction checkpoint. With compaction.mode: "default", the in-session auto-compaction checkpoint captures the prompt and flushes the agent's Scope while the Gateway runs. The transcript is too short for OpenClaw to compact anything (it logs no_compactable_entries), so the case covers the checkpoint, not the compaction itself.
    • Server outage. A turn still completes when the Server is unreachable, without injected context.
  • tests/e2e/zcode_acceptance/protocol.py. Two changes to the shared HostModelFixture:
    • It compares tool call IDs without separators. OpenClaw strips them before replaying a call (call-<hex>-1 becomes call<hex>1); without this the fixture never sees its call acknowledged and repeats it forever.
    • A new streamed_prompt_tokens setting adds a usage chunk to streamed replies. The compaction case uses it to cross OpenClaw's threshold. It defaults to None, so other hosts' streams are unchanged.
  • CI. The openclaw-package job pins OPENCLAW_VERSION: '2026.8.1'. It installs that release from npm into $RUNNER_TEMP with --ignore-scripts, as the OpenCode job does, and checks its --version. It then runs the cases under Node 24.15.0 and uploads the Gateway logs on failure. A missing binary fails the step rather than skipping the cases.
  • Routing. .github/ci-paths.toml routes tests/e2e/zcode_acceptance/protocol.py and runner.py to the openclaw suite. tests/test_ci_changes.py adds the rows for those files and for the new test.

Are there any user-facing changes?

No. Test and CI only.

How was this change tested?

  • Real host: OpenClaw 2026.8.1 (ea80657) on macOS, installed with --ignore-scripts as CI installs it. All seven cases passed in three consecutive full runs with the Gateway on Node 24.16.0, taking 64–70 s each.
  • Bundle mutations: each mutation below was applied to the built dist/index.js, and the case meant to catch it was run. Every mutation was caught, and the bundle was restored after each one.
Mutation of dist/index.js Case that caught it
Prepared context is never injected Recall
Capture drops the run's project keys (reverts #2601) Scope resolution
Capture ignores autoCapture Settings
Recall ignores autoRecall Settings
Memory tools resolve without the session key Memory tools
Incognito session keys are treated as private Excluded sessions
Group session keys are treated as private Excluded sessions
before_compaction needs ctx.agentId (reverts #2622) Pre-compaction checkpoint
A failed prepare throws Server outage
A failed prepare never returns Server outage

The last two need the outage case's diagnostic check. OpenClaw catches a throwing before_prompt_build hook and times out a stuck one after 15 s, so the turn completes either way. The case therefore also asserts the plugin's own context_prepare / server_unavailable diagnostic, and the absence of OpenClaw's hook-failure log line.

  • uv run pytest tests/test_ci_changes.py: 159 passed. uv run pytest tests/test_zcode_acceptance_protocol.py: 18 passed.
  • make openclaw-plugin-test (109 tests, type check, build) and make check pass.

Not validated:

  • CI runner. The CI job itself has not run yet. Linux, Node 24.15.0, and the npm install from the registry are exercised only by this PR's CI. The install pins openclaw@2026.8.1 but not its dependencies, which npm resolves on each run.
  • Checkpoint budget. The compaction case waits up to 15 s for the capture and the flushed Memory. It does not assert that the flush finished within the plugin's 1 s closing budget: in one run under heavy load, the plugin logged pre_compaction_checkpoint / deadline_exceeded, and the flush completed afterwards.
  • Other hosts and modes. Other OpenClaw releases, channels, the TUI, openclaw agent --local, and compaction modes other than default were not run.
  • Live behavior. The model and the Server's generation model are local fixtures, so live-model behavior is not covered.

Findings from the real host that remain open (none is changed here):

  • Pre-compaction checkpoint and project bindings. No OpenClaw 2026.8.1 before_compaction context carries activeProjectKeys. With a project binding, the checkpoint can capture into the agent or default Scope instead of the project Scope the turn's recall reads. This needs a separate fix.
  • Setup and the documented minimum version. powercontext setup openclaw requires plugins install --no-enable, and its error names 2026.9.7. The docs and the plugin manifest say 2026.8.1-beta.2 or newer, and 2026.8.1 has no --no-enable. The docs also describe setup as running plugins install --link --force, while the code installs a packed archive with --force --no-enable.
  • Linked installs on 2026.8.1. OpenClaw 2026.8.1 requires --accept-capabilities to install this plugin. The documented --link --force command omits it.
  • Tool descriptors in excluded sessions. OpenClaw caches plugin tool descriptors without the session key, so group and incognito sessions are still offered the memory tools. Calling one fails inside the plugin, and nothing reaches the Server. No documented promise covers this, so the cases do not assert it.
  • One-shot local turns. openclaw agent --local runs agent_end hooks fire-and-forget. A one-shot local turn can exit before the capture request is sent, which is why these cases use the Gateway.

Design notes for the cases and CI wiring:

  • Every case that expects a capture waits for it while the Gateway is still running, because OpenClaw does not wait for agent_end hooks before it shuts down.
  • The compaction case polls for the flushed Memory instead of asserting it right after the capture.
  • The outage case looks for the plugin's positive diagnostic anywhere in the Gateway log, so neither a reworded OpenClaw log line nor an earlier plugin diagnostic decides the result.
  • The Gateway process is stopped if its readiness check raises.
  • The host install uses --ignore-scripts, and the log upload skips pytest's *current links, which would otherwise upload each log twice.

AI usage statement

Claude Code (Claude Opus 5.5) investigated the OpenClaw host behavior, wrote the tests and CI wiring, and ran the real-host validation and mutations above.

A pinned OpenClaw 2026.8.1 Gateway loads the plugin's built bundle and
serves turns against a real PowerContext Server and a deterministic model
fixture. Seven cases cover recall, Scope resolution, the recall and
capture settings, memory tools, excluded sessions, the in-session
pre-compaction checkpoint, and a Server outage. The openclaw-package job
installs the pinned host and runs them.

The shared model fixture compares tool call IDs without separators,
because OpenClaw strips them before it replays a call, and it can report
prompt usage in streamed replies so a host compacts.
@AlexStocks AlexStocks added the 1.6.0 v1.6.0 release tracking label Nov 17, 2026

def _call_identity(value: Any) -> str:
"""A tool call ID as hosts may replay it: without separators."""
return re.sub(r"[^A-Za-z0-9]", "", value) if isinstance(value, str) else ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 共享 fixture 放宽了 tool_call_id 相等判定,6 条宿主验收链因此失去区分被改写 ID 的能力

_call_identity()(:43-45,本 PR 新增)把任何非字母数字字符全部剥掉后比较(:245 使用处):

def _call_identity(value: Any) -> str:
    return re.sub(r"[^A-Za-z0-9]", "", value) if isinstance(value, str) else ""

base 上这里是严格相等(message.get("tool_call_id") == self.pending["tool_calls"][0]["id"])。放宽后 _call_identity("call_1") == _call_identity("call-1") == "call1"——两个协议上不同的调用会被判为"同一调用已确认"。

该 fixture 是共享实现:本 PR 在 tests/test_ci_changes.py:289-290 把消费者从 {tests,zcode,pi,opencode,codex,bub} 扩成再加 openclaw,即 6 条宿主验收链全部改用去分隔符比较。改动动机(OpenClaw 会剥掉分隔符)是真实的,但正确的做法是给 openclaw 单独声明它的规范化规则,而不是让其余 5 条链的断言同时失去区分能力——这类 e2e 的核心目的之一就是证明宿主把工具结果回填到原来的调用上。

建议:比较改为"严格相等,或仅在 openclaw 用例显式开启的规范化模式"(fixture 上加开关),并保留对原始 ID 字符集差异的记录,避免影响其余 5 条链。

@AlexStocks
AlexStocks merged commit 63e8488 into oceanbase:master Nov 17, 2026
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants